package com.jbp.service.impl;

import com.jbp.config.GlobConfig;
import com.jbp.dao.LotteryDao;
import com.jbp.domin.LuckReq;
import com.jbp.domin.LuckReq2;
import com.jbp.exception.RRException;
import com.jbp.model.*;
import com.jbp.redis.RedisConfigService;
import com.jbp.service.*;
import com.jbp.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

@Service
public class LotteryServiceImpl extends ServiceImpl<LotteryDao, Lottery> implements LotteryService {
    @Autowired
    private GiftLotService giftLotService;

    @Autowired
    private GiftService giftService;

    @Autowired
    private WalletService walletService;

    @Autowired
    private WalletRecordService walletRecordService;

    @Autowired
    private RankProportionService rankProportionService;

    @Autowired
    private PrizeDeployService prizeDeployService;

    @Autowired
    private PrizePatchService prizePatchService;

    @Autowired
    private UserPacksackService userPacksackService;

    @Autowired
    private UserService userService;

    @Autowired
    private PushService pushService;

    @Autowired
    private UserDailyLuckRecordService userDailyLuckRecordService;


    @Autowired
    private LuckyUtil102 luckyUtilSmall;
    @Autowired
    private LuckyUtil42 luckUtilBig;
    @Autowired
    private LuckyUtil43 luckUtilFour;
    @Autowired
    private PropertyService propertyService;

    @Autowired
    private LuckRankService luckRankService;
    @Autowired
    private UserLevelService userLevelService;

    @Autowired
    private LotteryRecordService lotteryRecordService;
    @Autowired
    private RedisConfigService redisConfigService;

    @Override
    public void saveLots(List<Lottery> lotList) {
        saveBatch(lotList);
    }

    @Autowired
    private LuckVUtil luckVUtil;
    @Autowired
    private PoolService poolService;
    @Autowired
    private PoolXUserService poolXUserService;

    @Autowired
    private DevicePoolService devicePoolService;

    @Autowired
    private PoolGiftConfigService poolGiftConfigService;


    /**爆率版抽奖*/
    @Transactional
    @Override
    public synchronized R luck(LuckReq luckReq) {
        Date data=new Date();

        //抽奖类型twenty 20钻抽 hundred 100钻抽
        int poolType = propertyService.getCoin(luckReq.getPoolType());

        //one 单抽 ten 十抽  hundred 百抽
        int type = GlobConfig.getType(luckReq.getType());

        //本次抽奖需要花费的心钻
        int xinZuan = poolType*type;

        //检查当天投入
//        checkTotalPayTaday(luckReq.getPoolType(), luckReq.getUserId(), xinZuan);

        //检查余额
        checkWallet(luckReq.getUserId(), xinZuan);

        String deplopType = "hundred";

        //检查奖池
        Integer poolId = getPoolId(luckReq.getPoolType(), deplopType);

        //取奖池礼物配置
        List<GiftLot> list = giftLotService.listByPoolType(luckReq.getPoolType());

        // 记录中奖信息
        List<Lottery> lotList = new ArrayList<>();

        // 中奖礼物
        List<Gift> gifts = new ArrayList<>();

        //抽补池
        List<Gift>  patchGifts = prizePatchService.luck(luckReq.getUserId(), 1, type);
        gifts.addAll(patchGifts);
        type = type - patchGifts.size();

        if ("small".equalsIgnoreCase(luckReq.getPoolType())) {
            gifts.addAll(luckyUtilSmall.luck(luckReq.getUserId(), type, list, patchGifts.size(), luckReq.getRoomId()));
        } else if ("four".equalsIgnoreCase(luckReq.getPoolType())) {
            gifts.addAll(luckUtilFour.luck(luckReq.getUserId(), type, list, patchGifts.size(), luckReq.getRoomId()));
        } else {
            gifts.addAll(luckUtilBig.luck(luckReq.getUserId(), type, list, patchGifts.size(), luckReq.getRoomId()));
        }

        LotteryRecord lotteryRecord = lotteryRecordService.create(luckReq.getPoolType(), luckReq.getType(), poolId, luckReq.getRoomId(), luckReq.getUserId());
        int income = 0;
        int maxPrice = 0;
        //礼物分组
        Map<Integer,Integer> map=new HashMap<>();
        for (Gift gift : gifts) {
            Integer giftId = gift.getId();
            if (map.containsKey(giftId)){
                map.put(giftId,map.get(giftId)+1);
            }else{
                map.put(giftId,1);
            }

            Lottery lot = new Lottery();
            lot.setGiftId(gift.getId());
            lot.setGiftNum(gift.getCoin());
            lot.setCreateTime(new Date());
            lot.setLotteryRecordId(lotteryRecord.getId());
            lotList.add(lot);

            maxPrice = Math.max(maxPrice, gift.getCoin());
            income += gift.getCoin();
        }

        //保存抽奖详情
        this.saveLots(lotList);
        lotteryRecord.setIncome(income);
        lotteryRecord.setPay(xinZuan);
        lotteryRecord.setMaxPrice(maxPrice);
        lotteryRecordService.updateById(lotteryRecord);

        WalletRecord walletRecord = new WalletRecord();
        Wallet wallet = walletService.getByUserId(luckReq.getUserId());
        if (wallet.getScore().compareTo(new BigDecimal(xinZuan))>=0 ){
            //钱包金额变更
            walletRecord.setBeforeBalance(wallet.getScore());
            wallet.setScore(wallet.getScore().subtract(new BigDecimal(xinZuan)));

            walletRecord.setAfterBalance(wallet.getScore());
            walletRecord.setCoinType("score");
            walletRecord.setChangeBalance(new BigDecimal(xinZuan));
        } else {
            //钱包金额变更
            walletRecord.setBeforeBalance(wallet.getXinzuan());
            wallet.setXinzuan(wallet.getXinzuan().subtract(new BigDecimal(xinZuan)));
            walletRecord.setAfterBalance(wallet.getXinzuan());
            walletRecord.setCoinType("xinzuan");
            walletRecord.setChangeBalance(new BigDecimal(xinZuan));

            //百万奖池金额处理
            rankProportionService.addPrizePoolAmount(walletRecord.getChangeBalance());
        }
        walletRecord.setAddType("sub");
        walletRecord.setUserId(wallet.getUserId());
        walletRecord.setOperationType("lucky");
        walletRecord.setCreateTime(data);
        walletRecordService.save(walletRecord);

        /**
         * 加入背包
         */
        for (Integer giftId: map.keySet()) {
            UserPacksack packsack = userPacksackService.getByUserAndGift(luckReq.getUserId(),giftId);
            if (packsack == null){
                packsack=new UserPacksack();
                packsack.setGiftId(giftId);
                packsack.setUserId(luckReq.getUserId());
                packsack.setNumber(map.get(giftId));
                packsack.setCreateTime(new Date());
                userPacksackService.save(packsack);
            }else{
                packsack.setNumber(packsack.getNumber()+map.get(giftId));
                packsack.setUpdateTime(new Date());
                userPacksackService.updateById(packsack);
            }
        }
        walletService.updateWithLock(wallet);

        User user = userService.getById(luckReq.getUserId());

        //跟新每日抽奖统计
        UserDailyLuckRecord userDailyLuckRecord = userDailyLuckRecordService.getRecordByToday(user.getId(), luckReq.getRoomId(), luckReq.getPoolType(), deplopType, 0);
        if (userDailyLuckRecord==null) {
            userDailyLuckRecord = new UserDailyLuckRecord();
            userDailyLuckRecord.setType(deplopType);
            userDailyLuckRecord.setPoolType(luckReq.getPoolType());
            userDailyLuckRecord.setUserId(user.getId());
            userDailyLuckRecord.setLuckDate(new Date());
            userDailyLuckRecord.setPay(xinZuan);
            userDailyLuckRecord.setIncome((int) income);
            userDailyLuckRecord.setRoomId(luckReq.getRoomId());
            userDailyLuckRecordService.save(userDailyLuckRecord);
        } else {
            userDailyLuckRecord.setPay(userDailyLuckRecord.getPay()+xinZuan);
            userDailyLuckRecord.setIncome(userDailyLuckRecord.getIncome()+ (int) income);
            userDailyLuckRecordService.updateById(userDailyLuckRecord);
        }

        List<Gift> giftList=new ArrayList<>();
        for (Integer giftId : map.keySet()) {
            Gift gift=giftService.getById(giftId);
            gift.setNum(map.get(giftId));
            giftList.add(gift);
        }
        //更新手气榜
//        luckRankService.saveLuckRank(lotteryRecord, giftList);
        return R.ok().put("data", giftList);
    }

    @Override
    @Transactional
    public R luck2(LuckReq2 luckReq) {
        int times = luckReq.getTimes();
        int price = luckReq.getPrice();
        //本次抽奖需要花费的心钻
        int xinZuan = times*price;
        //检查余额
        checkWallet(luckReq.getUserId(), xinZuan);
        //检查当天投入
        checkTotalPayTaday(price+"", luckReq.getUserId(), xinZuan);

        List<Gift> gifts = new ArrayList<>();
        int poolId = 0;

        PoolXUser poolXUser = null;
        //补池
        List<Gift>  patchGifts = prizePatchService.luck(luckReq.getUserId(), price, times);
        gifts.addAll(patchGifts);

        //判断是否在设备池中,设备池优先级最高
        User user = userService.getById(luckReq.getUserId());
        DevicePool devicePool = null;
        if (null != user.getDevice() && !"".equals(user.getDevice())) {
            String device = user.getDevice();
            devicePool = devicePoolService.getOne(new QueryWrapper<DevicePool>().eq("device_name", device));
        }

        if (devicePool != null){
            if (gifts.size()<times){
                String poolName = devicePool.getPoolName();//设备池名称
                luckReq.setPoolName(poolName);
                luckReq.setDeviceId(devicePool.getId());
                Pool pool = poolService.getDevicePool(luckReq);
                poolId = pool.getId();
                luckReq.setTimes(times-gifts.size());

                int luckGifts = redisConfigService.getInt("luckGifts"+luckReq.getUserId()+":"+pool.getId());

                //抽奖
//            List<Gift> luckGifts = luckVUtil.luck(luckReq, pool, 0);
                List<Gift> luckGiftNumbers = luckVUtil.luckDevice(luckReq, pool, 0);
                luckGifts = luckGifts + luckGiftNumbers.size();
                redisConfigService.set("luckGifts"+luckReq.getUserId()+":"+pool.getId(), luckGifts);

                //奖池礼物列表
                List<PoolGiftConfig> poolGiftConfigList = poolGiftConfigService.list(new QueryWrapper<PoolGiftConfig>().eq("pool_id", poolId));
                if (!poolGiftConfigList.isEmpty()) {
                    Integer giftNum = 0;
                    for (PoolGiftConfig poolGiftConfig : poolGiftConfigList) {
                        giftNum = giftNum + poolGiftConfig.getGiftNum();
                    }
                    if (luckGifts >= giftNum) {
                        devicePoolService.removeById(luckReq.getDeviceId());
                        redisConfigService.set("luckGifts"+luckReq.getUserId()+":"+pool.getId(), 0);
                        System.out.println("从设备池移除了。");
                    }
                }
                gifts.addAll(luckGiftNumbers);
            }
        }else {
            if (gifts.size()<times) {
                //取黑白池
                poolXUser = poolXUserService.getByPrice(luckReq.getUserId(), luckReq.getPrice());
                Pool pool;
                Integer poolXUserId = 0;
                if (poolXUser != null) {
                    pool = poolService.getById(poolXUser.getPoolId());
                    poolXUserId = poolXUser.getId();
                } else {
                    pool = poolService.getPool(luckReq);
                }
                if (pool == null) {
                    throw new RRException("敬请期待");
                }

                poolId = pool.getId();
                luckReq.setTimes(times-gifts.size());
                //抽奖
                List<Gift> luckGifts = luckVUtil.luck(luckReq, pool, poolXUserId);
                gifts.addAll(luckGifts);
            }
        }

        // 记录中奖信息
        List<Lottery> lotList = new ArrayList<>();
//        LotteryRecord lotteryRecord = lotteryRecordService.create(price+"", times+"", poolId, luckReq.getRoomId(), luckReq.getUserId());
        int income = 0;
        int maxPrice = 0;
        //礼物分组
        Map<Integer,Integer> map=new HashMap<>();
        for (Gift gift : gifts) {
            Integer giftId = gift.getId();
            if (map.containsKey(giftId)){
                map.put(giftId,map.get(giftId)+1);
            }else{
                map.put(giftId,1);
            }
            maxPrice = Math.max(maxPrice, gift.getCoin());
            income += gift.getCoin();
        }


        //跟新每日抽奖统计
        UserDailyLuckRecord userDailyLuckRecord = userDailyLuckRecordService.getRecordByToday(luckReq.getUserId(), luckReq.getRoomId(), price+"", times+"", poolId);
        if (userDailyLuckRecord==null) {
            userDailyLuckRecord = new UserDailyLuckRecord();
            userDailyLuckRecord.setType(times+"");
            userDailyLuckRecord.setPoolType(price+"");
            userDailyLuckRecord.setUserId(luckReq.getUserId());
            userDailyLuckRecord.setLuckDate(new Date());
            userDailyLuckRecord.setPay(xinZuan);
            userDailyLuckRecord.setPoolId(poolId);
            userDailyLuckRecord.setIncome((int) income);
            userDailyLuckRecord.setRoomId(luckReq.getRoomId());
            userDailyLuckRecord.setUpdateTime(new Date());
            userDailyLuckRecordService.save(userDailyLuckRecord);

        } else {
            userDailyLuckRecord.setPay(userDailyLuckRecord.getPay()+xinZuan);
            userDailyLuckRecord.setIncome(userDailyLuckRecord.getIncome()+ (int) income);
            userDailyLuckRecord.setUpdateTime(new Date());
            userDailyLuckRecordService.updateById(userDailyLuckRecord);
        }


//        LotteryRecord lotteryRecord = lotteryRecordService.create(price+"", times+"", poolId, luckReq.getRoomId(), luckReq.getUserId());
        LotteryRecord lotteryRecord =  new LotteryRecord();
        //保存抽奖详情
        lotteryRecord.setCreateTime(new Date());
        lotteryRecord.setPoolType(price+"");
        lotteryRecord.setType(times+"");
        lotteryRecord.setPoolId(poolId);
        lotteryRecord.setRoomId(luckReq.getRoomId());
        lotteryRecord.setUserId(luckReq.getUserId());
        lotteryRecord.setIncome(income);
        lotteryRecord.setPay(xinZuan);
        lotteryRecord.setMaxPrice(maxPrice);
//        lotteryRecord.setCreateTime(userDailyLuckRecord.getUpdateTime());
//        lotteryRecordService.updateById(lotteryRecord);
        lotteryRecordService.save(lotteryRecord);

        //钱包金额变更
        WalletRecord walletRecord = new WalletRecord();
        Wallet wallet = walletService.getByUserId(luckReq.getUserId());
        if (wallet.getScore().compareTo(new BigDecimal(xinZuan))>=0 ){
            //钱包金额变更
            walletRecord.setBeforeBalance(wallet.getScore());
            wallet.setScore(wallet.getScore().subtract(new BigDecimal(xinZuan)));
            walletRecord.setAfterBalance(wallet.getScore());
            walletRecord.setCoinType("score");
            walletRecord.setChangeBalance(new BigDecimal(xinZuan));
        } else {
            //钱包金额变更
            walletRecord.setBeforeBalance(wallet.getXinzuan());
            wallet.setXinzuan(wallet.getXinzuan().subtract(new BigDecimal(xinZuan)));
            walletRecord.setAfterBalance(wallet.getXinzuan());
            walletRecord.setCoinType("xinzuan");
            walletRecord.setChangeBalance(new BigDecimal(xinZuan));
            //百万奖池金额处理
            rankProportionService.addPrizePoolAmount(walletRecord.getChangeBalance());
        }
        walletRecord.setAddType("sub");
        walletRecord.setUserId(wallet.getUserId());
        walletRecord.setOperationType("lucky");
        walletRecord.setCreateTime(new Date());
        walletRecordService.save(walletRecord);
        walletService.updateWithLock(wallet);

        //加入背包
        for (Integer giftId: map.keySet()) {
            UserPacksack packsack = userPacksackService.getByUserAndGift(luckReq.getUserId(),giftId);
            if (packsack == null){
                packsack=new UserPacksack();
                packsack.setGiftId(giftId);
                packsack.setUserId(luckReq.getUserId());
                packsack.setNumber(map.get(giftId));
                packsack.setCreateTime(new Date());
                userPacksackService.save(packsack);
            }else{
                packsack.setNumber(packsack.getNumber()+map.get(giftId));
                packsack.setUpdateTime(new Date());
                userPacksackService.updateById(packsack);
            }

        }



//        System.out.println(userDailyLuckRecord.toString());

        //跟新黑白池
        if (poolXUser!=null) {
            poolXUser.setPay(poolXUser.getPay()+xinZuan);
            poolXUser.setIncome(poolXUser.getIncome() + income);
            if (poolXUser.getPay()>=poolXUser.getExpectPay()) {
                poolXUser.setDel(2);
            }
            poolXUserService.updateById(poolXUser);

        }

        //更新手气榜
        List<Gift> giftList = new ArrayList<>();
        for (Integer giftId : map.keySet()) {
            Gift gift=giftService.getById(giftId);
            gift.setNum(map.get(giftId));
            giftList.add(gift);
        }
        luckRankService.saveLuckRank(price,lotteryRecord, giftList);

        //保存抽奖详情
        for (Gift gift : giftList) {
            Lottery lot = new Lottery();
            lot.setGiftId(gift.getId());
            lot.setGiftNum(gift.getNum());
            lot.setCreateTime(new Date());
            lot.setLotteryRecordId(lotteryRecord.getId());
            lotList.add(lot);
        }
        this.saveLots(lotList);

        pushService.bigLucky(luckReq.getUserId(), price, giftList);
        return R.ok().put("data", giftList);
    }

    /** 检查奖池 */
    private Integer getPoolId(String poolType, String deplopType) {
        PrizeDeploy prizeDep  = prizeDeployService.getOne(new QueryWrapper<PrizeDeploy>()
                .eq("pool_type", poolType)
                .eq("type", deplopType)
                .isNull("user_id"));
        if (prizeDep == null){
            throw new RRException("操作失误");
        }
        return prizeDep.getId();
    }

    /** 检查钱包余额 */
    private void checkWallet(Integer userId, int xinZuan) {
        Wallet wallet = walletService.getByUserId(userId);
        if ((wallet.getScore().compareTo(new BigDecimal(xinZuan)))<0
                && (wallet.getXinzuan().compareTo(new BigDecimal(xinZuan)))<0){
            throw  new RRException("钱包余额不足");
        }
    }

    /** 检查每日投入限制 */
    private void checkTotalPayTaday(String poolType, Integer userId, int currPay) {
        //每天投入不超过10000钻
        double totalPay = userDailyLuckRecordService.getPayToday(userId, poolType);
        int biggestLuck = propertyService.getInt("biggest_luck_one_day");
        if (currPay + totalPay>biggestLuck) {
            throw new RRException("请明天再试");
        }
    }

    @Override
    public List<Lottery> personRecord(Map<String, Object> params) {
       List<Lottery> lotteryList = baseMapper.personRecord(params);
       /*if (lotteryList != null && lotteryList.size() > 0){
           lotteryList.forEach(list -> {
               //根据UUID查询每次
               List<Lottery> lotList = this.list(new QueryWrapper<Lottery>().eq("lottery_uuid", list.getLotteryUuid()));
               //查询每次抽的总数
               list.setCount(lotList.size());
               Map<Integer,Integer> map =new HashMap<>();
               for (int i = 0; i < lotList.size(); i++) {//循环获取记录里每一份礼物获取了多少份
                   if (map.containsKey(lotList.get(i).getGiftId())){
                       map.put(lotList.get(i).getGiftId(),map.get(lotList.get(i).getGiftId())+1);
                   }else{
                       map.put(lotList.get(i).getGiftId(),1);
                   }
               }

               List<Lottery> lList = new ArrayList<>();
               for (Integer key:
                       map.keySet()) {
                    Gift gift = giftService.getById(key);
                    Lottery lottery = new Lottery();
                   //记录礼物名称
                   lottery.setGiftName(gift.getName());
                   //记录每一份礼物总数
                   lottery.setGiftCount(map.get(key));
                   lList.add(lottery);
               }
               list.setLotList(lList);
           });
       }*/
       return lotteryList;
    }

    @Override
    public List<PersonLottery> personLottery(Map<String, Object> params) {
        return baseMapper.personLottery(params);
    }

//    @Override
//    public List<Lottery> cufflList(Map<String,Object> params) {
//        return baseMapper.cufflList(params);
//    }

    public boolean isUuidExits(String uuid) {
        QueryWrapper<Lottery> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("lottery_uuid",uuid);
        return this.getOne(queryWrapper) != null;
    }


    @Override
    public Integer personCount(Map<String, Object> params) {
        Integer num=baseMapper.personCount(params);
        return num == null ? 0 : num;
    }

    @Override
    public Integer personLotteryCount(Map<String, Object> params) {
        Integer num= baseMapper.personLotteryCount(params);
        return num == null ? 0 : num;
    }

    @Override
    public long getZrjc() {
        return baseMapper.getZrjc();
    }

    @Override
    public long getJrjc() {
        return baseMapper.getJrjc();
    }

    @Override
    public long getZjc(String startDate, String endDate) {
        return baseMapper.getZjc(startDate, endDate);
    }
    @Override
    public long getZjc2(String startDate, String endDate) {
        return baseMapper.getZjc2(startDate, endDate);
    }

    @Override
    public List<EventUserLuckBangdanModel> getZrBd() {
        return baseMapper.getZrBd();
    }

    @Override
    public List<EventUserLuckBangdanModel> getJrBd() {
        return baseMapper.getJrBd();
    }

    @Override
    public List<EventUserLuckBangdanModel> getZBd(String startDate, String endDate) {
        return baseMapper.getZBd(startDate, endDate);
    }

    @Override
    public List<LianMengBangdanModel> getLianMengBd(String startDate, String endDate) {
        return baseMapper.getLianMengBd(startDate, endDate);
    }


    @Override
    public List<LianMengBangdanModel> getHahaniuHd1Bd(String startDate, String endDate) {
        return baseMapper.getHahaniuHd1Bd(startDate, endDate);
    }

    @Override
    public List<LianMengBangdanModel> getHahaniuHd2Bd(String startDate, String endDate) {
        return baseMapper.getHahaniuHd2Bd(startDate, endDate);
    }
    @Override
    public List<LianMengBangdanModel> getNaonaoHd1Bd(String startDate, String endDate) {
        return baseMapper.getNaonaoHd1Bd(startDate, endDate);
    }

    @Override
    public List<EventUserLuckBangdanModel> getZrBdYk() {
        return baseMapper.getZrBdYk();
    }

    @Override
    public List<EventUserLuckBangdanModel> getJrBdYk() {
        return baseMapper.getJrBdYk();
    }

    @Override
    public List<EventUserLuckBangdanModel> getZBdYk(String startDate, String endDate) {
        return baseMapper.getZBdYk(startDate, endDate);
    }

    @Override
    public List<EventUserLuckBangdanModel> getYukalist(String startDate, String endDate) {
        return baseMapper.getYukalist(startDate, endDate);
    }

    @Override
    public int getHaiouCount() {
        return baseMapper.getHaiouCount();
    }

    @Override
    public List<EventUserLuckBangdanModel> getHaiouBd1() {
        return baseMapper.getHaiozuBd1();
    }
    @Override
    public List<EventUserLuckBangdanModel> getHaiouBd2() {
        return baseMapper.getHaiozuBd2();
    }
    @Override
    public List<EventUserLuckBangdanModel> getHaiouBd3() {
        return baseMapper.getHaiozuBd3();
    }
    @Override
    public List<EventUserLuckBangdanModel> getHaiouBd4() {
        return baseMapper.getHaiozuBd4();
    }

    @Override
    public List<UserLianMengModel> getLianMengBdInroom(String startDate, String endDate, Integer roomId) {
        return baseMapper.getLianMengBdInroom(startDate, endDate, roomId);
    }

    @Override
    public List<EventUserLuckBangdanModel> getZBdPay(String startDate, String endDate) {
        return baseMapper.getZBdPay(startDate, endDate);
    }
    @Override
    public List<EventUserLuckBangdanModel> getRoomZBdPay(String startDate, String endDate) {
        return baseMapper.getRoomZBdPay(startDate, endDate);
    }

    @Override
    public Integer todayCount(Integer uid, Integer giftId) {
        return baseMapper.todayCount(uid, giftId);
    }

    @Override
    public List<RoomRate> roomRate() {
        return baseMapper.roomRate();
    }

    @Override
    public List<RoomRate> ipRate() {
        return baseMapper.ipRate();
    }

    @Override
    public List<RoomRate> deviceRate() {
        return baseMapper.deviceRate();
    }
}
